package cn.cool.aop;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MailSender implements InvocationHandler {
    private final Object target;

    public MailSender(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("1");
        Object result = method.invoke(target, args); //target.login(user)
        System.out.println("2");
        return result;
    }
}
